﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XcoAppSpaces.Core.Ports;

namespace test.XcoAppSpaces.Core.Ports
{
	/// <summary>
	/// Helper methods for shorter RegisterReceiver calls
	/// </summary>
	static class TestHelpers
	{
		public static void RegisterReceiver<T>(this Port<T> port, Action<T> receiver, int maxDegreeOfParallelism)
		{
			port.RegisterReceiver(receiver, new PortReceiverOptions{MaxDegreeOfParallelism = maxDegreeOfParallelism});
		}

		public static void RegisterReceiver<T>(this Port<T> port, Func<T, Task> receiver, int maxDegreeOfParallelism)
		{
			port.RegisterReceiver(receiver, new PortReceiverOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism });
		}
	}
}
